<!doctype html>



  


<html class="theme-next mist use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="baidu-site-verification" content="zD47G9xe42" />


<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="数据库设计," />





  <link rel="alternate" href="/atom.xml" title="uiste" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.1" />






<meta name="description" content="数据库设计123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101">
<meta property="og:type" content="article">
<meta property="og:title" content="数据库设计-商城购物系统">
<meta property="og:url" content="http://blog.uiste.com/20161017-3.html">
<meta property="og:site_name" content="uiste">
<meta property="og:description" content="数据库设计123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101">
<meta property="og:updated_time" content="2016-10-31T17:14:14.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="数据库设计-商城购物系统">
<meta name="twitter:description" content="数据库设计123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 0,
      author: '博主'
    }
  };
</script>




  <link rel="canonical" href="http://blog.uiste.com/20161017-3.html"/>

  <title>
 数据库设计-商城购物系统 | uiste 
</title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  



  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?b58b87af012832b8ae35e33bb45b44fa";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>








  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">uiste</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">uiste个人博客</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      

            <li class="menu-item menu-item-search"> <a title="把这个链接拖到你的Chrome收藏夹工具栏中" href='javascript:(function() {
    function c() {
        var e = document.createElement("link");
        e.setAttribute("type", "text/css");
        e.setAttribute("rel", "stylesheet");
        e.setAttribute("href", f);
        e.setAttribute("class", l);
        document.body.appendChild(e)
    }
 
    function h() {
        var e = document.getElementsByClassName(l);
        for (var t = 0; t < e.length; t++) {
            document.body.removeChild(e[t])
        }
    }
 
    function p() {
        var e = document.createElement("div");
        e.setAttribute("class", a);
        document.body.appendChild(e);
        setTimeout(function() {
            document.body.removeChild(e)
        }, 100)
    }
 
    function d(e) {
        return {
            height : e.offsetHeight,
            width : e.offsetWidth
        }
    }
 
    function v(i) {
        var s = d(i);
        return s.height > e && s.height < n && s.width > t && s.width < r
    }
 
    function m(e) {
        var t = e;
        var n = 0;
        while (!!t) {
            n += t.offsetTop;
            t = t.offsetParent
        }
        return n
    }
 
    function g() {
        var e = document.documentElement;
        if (!!window.innerWidth) {
            return window.innerHeight
        } else if (e && !isNaN(e.clientHeight)) {
            return e.clientHeight
        }
        return 0
    }
 
    function y() {
        if (window.pageYOffset) {
            return window.pageYOffset
        }
        return Math.max(document.documentElement.scrollTop, document.body.scrollTop)
    }
 
    function E(e) {
        var t = m(e);
        return t >= w && t <= b + w
    }
 
    function S() {
        var e = document.createElement("audio");
        e.setAttribute("class", l);
        e.src = i;
        e.loop = false;
        e.addEventListener("canplay", function() {
            setTimeout(function() {
                x(k)
            }, 500);
            setTimeout(function() {
                N();
                p();
                for (var e = 0; e < O.length; e++) {
                    T(O[e])
                }
            }, 15500)
        }, true);
        e.addEventListener("ended", function() {
            N();
            h()
        }, true);
        e.innerHTML = " <p>If you are reading this, it is because your browser does not support the audio element. We recommend that you get a new browser.</p> <p>";
        document.body.appendChild(e);
        e.play()
    }
 
    function x(e) {
        e.className += " " + s + " " + o
    }
 
    function T(e) {
        e.className += " " + s + " " + u[Math.floor(Math.random() * u.length)]
    }
 
    function N() {
        var e = document.getElementsByClassName(s);
        var t = new RegExp("\\b" + s + "\\b");
        for (var n = 0; n < e.length; ) {
            e[n].className = e[n].className.replace(t, "")
        }
    }
 
    var e = 30;
    var t = 30;
    var n = 350;
    var r = 350;
    var i = "//s3.amazonaws.com/moovweb-marketing/playground/harlem-shake.mp3";
    var s = "mw-harlem_shake_me";
    var o = "im_first";
    var u = ["im_drunk", "im_baked", "im_trippin", "im_blown"];
    var a = "mw-strobe_light";
    var f = "//s3.amazonaws.com/moovweb-marketing/playground/harlem-shake-style.css";
    var l = "mw_added_css";
    var b = g();
    var w = y();
    var C = document.getElementsByTagName("*");
    var k = null;
    for (var L = 0; L < C.length; L++) {
        var A = C[L];
        if (v(A)) {
            if (E(A)) {
                k = A;
                break
            }
        }
    }
    if (A === null) {
        console.warn("Could not find a node of the right size. Please try a different page.");
        return
    }
    c();
    S();
    var O = [];
    for (var L = 0; L < C.length; L++) {
        var A = C[L];
        if (v(A)) {
            O.push(A)
        }
    }
})()    '>High</a> </li>

    </ul>
  

 
    <div class="site-search">
      
  <div class="popup">
 <span class="search-icon fa fa-search"></span>
 <input type="text" id="local-search-input">
 <div id="local-search-result"></div>
 <span class="popup-btn-close">close</span>
</div>


    </div>
   
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                数据库设计-商城购物系统
              
            
          </h1>
        

        <div class="post-meta">
        
  <span id="busuanzi_container_page_pv">阅读量 <span id="busuanzi_value_page_pv"></span> 次</span>

          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-10-17T02:43:08+08:00" content="2016-10-17">
              2016-10-17
            </time>
          </span>

          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/20161017-3.html#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="20161017-3.html" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="数据库设计"><a href="#数据库设计" class="headerlink" title="数据库设计"></a>数据库设计</h2><figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div><div class="line">112</div><div class="line">113</div><div class="line">114</div><div class="line">115</div><div class="line">116</div><div class="line">117</div><div class="line">118</div><div class="line">119</div><div class="line">120</div><div class="line">121</div><div class="line">122</div><div class="line">123</div><div class="line">124</div><div class="line">125</div><div class="line">126</div><div class="line">127</div><div class="line">128</div><div class="line">129</div><div class="line">130</div><div class="line">131</div><div class="line">132</div><div class="line">133</div><div class="line">134</div><div class="line">135</div><div class="line">136</div><div class="line">137</div><div class="line">138</div><div class="line">139</div><div class="line">140</div><div class="line">141</div><div class="line">142</div><div class="line">143</div><div class="line">144</div><div class="line">145</div><div class="line">146</div><div class="line">147</div><div class="line">148</div><div class="line">149</div><div class="line">150</div><div class="line">151</div><div class="line">152</div><div class="line">153</div><div class="line">154</div><div class="line">155</div><div class="line">156</div><div class="line">157</div><div class="line">158</div><div class="line">159</div><div class="line">160</div><div class="line">161</div><div class="line">162</div><div class="line">163</div><div class="line">164</div><div class="line">165</div><div class="line">166</div><div class="line">167</div><div class="line">168</div><div class="line">169</div><div class="line">170</div><div class="line">171</div><div class="line">172</div><div class="line">173</div><div class="line">174</div><div class="line">175</div><div class="line">176</div><div class="line">177</div><div class="line">178</div><div class="line">179</div><div class="line">180</div><div class="line">181</div><div class="line">182</div><div class="line">183</div><div class="line">184</div><div class="line">185</div><div class="line">186</div><div class="line">187</div><div class="line">188</div><div class="line">189</div><div class="line">190</div><div class="line">191</div><div class="line">192</div><div class="line">193</div><div class="line">194</div><div class="line">195</div><div class="line">196</div><div class="line">197</div><div class="line">198</div><div class="line">199</div><div class="line">200</div><div class="line">201</div><div class="line">202</div><div class="line">203</div><div class="line">204</div><div class="line">205</div><div class="line">206</div><div class="line">207</div><div class="line">208</div><div class="line">209</div><div class="line">210</div><div class="line">211</div><div class="line">212</div><div class="line">213</div><div class="line">214</div><div class="line">215</div><div class="line">216</div><div class="line">217</div><div class="line">218</div><div class="line">219</div><div class="line">220</div><div class="line">221</div><div class="line">222</div><div class="line">223</div><div class="line">224</div><div class="line">225</div><div class="line">226</div><div class="line">227</div><div class="line">228</div><div class="line">229</div><div class="line">230</div><div class="line">231</div><div class="line">232</div><div class="line">233</div><div class="line">234</div><div class="line">235</div><div class="line">236</div><div class="line">237</div><div class="line">238</div><div class="line">239</div><div class="line">240</div><div class="line">241</div><div class="line">242</div><div class="line">243</div><div class="line">244</div><div class="line">245</div><div class="line">246</div><div class="line">247</div><div class="line">248</div><div class="line">249</div><div class="line">250</div><div class="line">251</div><div class="line">252</div><div class="line">253</div><div class="line">254</div><div class="line">255</div><div class="line">256</div><div class="line">257</div><div class="line">258</div><div class="line">259</div><div class="line">260</div><div class="line">261</div><div class="line">262</div><div class="line">263</div><div class="line">264</div><div class="line">265</div><div class="line">266</div><div class="line">267</div><div class="line">268</div><div class="line">269</div><div class="line">270</div><div class="line">271</div><div class="line">272</div><div class="line">273</div><div class="line">274</div><div class="line">275</div><div class="line">276</div><div class="line">277</div><div class="line">278</div><div class="line">279</div><div class="line">280</div><div class="line">281</div><div class="line">282</div><div class="line">283</div><div class="line">284</div><div class="line">285</div><div class="line">286</div><div class="line">287</div><div class="line">288</div><div class="line">289</div><div class="line">290</div><div class="line">291</div><div class="line">292</div><div class="line">293</div><div class="line">294</div><div class="line">295</div><div class="line">296</div><div class="line">297</div><div class="line">298</div><div class="line">299</div><div class="line">300</div><div class="line">301</div><div class="line">302</div><div class="line">303</div><div class="line">304</div><div class="line">305</div><div class="line">306</div><div class="line">307</div><div class="line">308</div></pre></td><td class="code"><pre><div class="line">/*</div><div class="line"> Navicat Premium Data Transfer</div><div class="line"></div><div class="line"> Source Server         : uiste</div><div class="line"> Source Server Type    : MySQL</div><div class="line"> Source Server Version : 50542</div><div class="line"> Source Host           : localhost</div><div class="line"> Source Database       : ugo</div><div class="line"></div><div class="line"> Target Server Type    : MySQL</div><div class="line"> Target Server Version : 50542</div><div class="line"> File Encoding         : utf-8</div><div class="line"></div><div class="line"> Date: 10/16/2016 14:27:21 PM</div><div class="line">*/</div><div class="line"></div><div class="line">#创建数据库</div><div class="line">create database ugo charset utf8;</div><div class="line">#选择数据库</div><div class="line">use ugou;</div><div class="line"></div><div class="line">/*------------------------------------商品模块---------------------------------------*/</div><div class="line">#创建商品类别表</div><div class="line">DROP TABLE IF EXISTS `ugo_category`;</div><div class="line">create table ugo_category(</div><div class="line">	cat_id smallint unsigned not null auto_increment primary key comment '商品类别ID',</div><div class="line">	cat_name varchar(30) not null default '' comment '商品类别名称',</div><div class="line">	cat_parent_id smallint unsigned not null default 0 comment '商品类别父ID',</div><div class="line">	cat_desc varchar(255) not null default '' comment '商品类别描述',</div><div class="line">	sort_order tinyint not null default 50 comment '排序依据',</div><div class="line">	unit varchar(15) not null default '' comment '单位',</div><div class="line">	is_show tinyint not null default 1 comment '是否显示，默认显示',</div><div class="line">	index pid(cat_parent_id)</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">#创建商品国家表</div><div class="line">DROP TABLE IF EXISTS `ugo_country`;</div><div class="line">create table ugo_country(</div><div class="line">	country_id smallint unsigned not null auto_increment primary key comment '国家ID',</div><div class="line">	country_name varchar(30) not null default '' comment '国家名称',</div><div class="line">	country_parent_name enum('亚洲','欧洲','北美洲','南美洲','非洲','大洋洲','南极洲') not null default '亚洲' comment '国家所属区域',</div><div class="line">	sort_order tinyint not null default 50 comment '排序依据',</div><div class="line">	is_show tinyint not null default 1 comment '是否显示，默认显示',</div><div class="line">	index pid(country_parent_name)</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">#创建商品品牌表</div><div class="line">DROP TABLE IF EXISTS `ugo_brand`;</div><div class="line">create table ugo_brand(</div><div class="line">	brand_id smallint unsigned not null auto_increment primary key comment '商品品牌ID',</div><div class="line">	brand_name varchar(30) not null default '' comment '商品品牌名称',</div><div class="line">	brand_desc varchar(255) not null default '' comment '商品品牌描述',</div><div class="line">	url varchar(100) not null default '' comment '商品品牌网址',</div><div class="line">	logo varchar(50) not null default '' comment '品牌logo',</div><div class="line">	sort_order tinyint unsigned not null default 50 comment '商品品牌排序依据',</div><div class="line">	is_show tinyint not null default 1 comment '是否显示，默认显示',</div><div class="line">	country_id smallint unsigned not null comment '商品品牌所属国家ID'</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">#创建商品类型表</div><div class="line">DROP TABLE IF EXISTS `ugo_attrtype`;</div><div class="line">create table ugo_attrtype(</div><div class="line">	type_id smallint unsigned not null auto_increment primary key comment '商品类型ID',</div><div class="line">	type_name varchar(50) not null default '' comment '商品类型名称'</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line"></div><div class="line">#创建商品属性表</div><div class="line">DROP TABLE IF EXISTS `ugo_attribute`;</div><div class="line">create table ugo_attribute(</div><div class="line">	attr_id smallint unsigned not null auto_increment primary key comment '商品属性ID',</div><div class="line">	attr_name varchar(50) not null default '' comment '商品属性名称',</div><div class="line">	type_id smallint not null default 0 comment '商品属性所属类型ID',</div><div class="line">	attr_input_type tinyint not null default 1 comment '属性录入方式 0为手工录入，1为从列表中选择，2为文本域',</div><div class="line">	attr_input_value text comment '属性的值',</div><div class="line">	index type_id(type_id)</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">#创建商品表</div><div class="line">DROP TABLE IF EXISTS `ugo_goods`;</div><div class="line">create table ugo_goods(</div><div class="line">	goods_id int unsigned not null auto_increment primary key comment '商品ID',</div><div class="line">	goods_sn varchar(30) not null default '' comment '商品货号',</div><div class="line">	goods_name varchar(100) not null default '' comment '商品名称',</div><div class="line">	goods_brief varchar(255) not null default '' comment '商品简单描述',</div><div class="line">	goods_slogan varchar(50) not null default '' comment '商品宣传语',</div><div class="line">	goods_desc text comment '商品详情',</div><div class="line">	cat_id smallint unsigned not null default 0 comment '商品所属类别ID',</div><div class="line">	brand_id smallint unsigned not null default 0 comment '商品所属品牌ID',</div><div class="line">	market_price decimal(10,2) not null default 0 comment '市场价格',</div><div class="line">	promote_price decimal(10,2) not null default 0 comment '促销价格',</div><div class="line">	promote_start_time int unsigned not null default 0 comment '促销起始时间',</div><div class="line">	promote_end_time int unsigned not null default 0 comment '促销截止时间',</div><div class="line">	goods_img varchar(50) not null default '' comment '商品图片',</div><div class="line">	goods_thumb varchar(50) not null default '' comment '商品缩略图',</div><div class="line">	goods_number smallint unsigned not null default 0 comment '商品库存',</div><div class="line">	click_count int unsigned not null default 0 comment '点击次数',</div><div class="line">	type_id smallint unsigned not null default 0 comment '商品类型ID',</div><div class="line">	is_promote tinyint unsigned not null default 0 comment '是否促销，默认为0不促销',</div><div class="line">	is_best tinyint unsigned not null default 0 comment '是否精品,默认为0',</div><div class="line">	is_new tinyint unsigned not null default 0 comment '是否新品，默认为0',</div><div class="line">	is_hot tinyint unsigned not null default 0 comment '是否热卖,默认为0',</div><div class="line">	is_onsale tinyint unsigned not null default 1 comment '是否上架,默认为1',</div><div class="line">	add_time int unsigned not null default 0 comment '添加时间',</div><div class="line">	index cat_id(cat_id),</div><div class="line">	index brand_id(brand_id),</div><div class="line">	index type_id(type_id)</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">#创建商品属性对应表</div><div class="line">DROP TABLE IF EXISTS `ugo_goods_attr`;</div><div class="line">create table ugo_goods_attr(</div><div class="line">	goods_attr_id int unsigned not null auto_increment primary key comment '编号ID',</div><div class="line">	goods_id int unsigned not null default 0 comment '商品ID',</div><div class="line">	attr_id smallint unsigned not null default 0 comment '属性ID',</div><div class="line">	attr_value varchar(255) not null default '' comment '属性值',</div><div class="line">	attr_price decimal(10,2) not null default 0 comment '属性价格',</div><div class="line">	index goods_id(goods_id),</div><div class="line">	index attr_id(attr_id)</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">#创建商品相册表</div><div class="line">DROP TABLE IF EXISTS `ugo_gallery`;</div><div class="line">create table ugo_gallery(</div><div class="line">	img_id int unsigned not null auto_increment primary key comment '图片编号',</div><div class="line">	goods_id int unsigned not null default 0 comment '商品ID',</div><div class="line">	img_url varchar(50) not null default '' comment '图片URL',</div><div class="line">	thumb_url varchar(50) not null default '' comment '缩略图URL',</div><div class="line">	img_desc varchar(50) not null default '' comment '图片描述',</div><div class="line">	index goods_id(goods_id)</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">/*------------------------------------商品模块 end-----------------------------------*/</div><div class="line"></div><div class="line"></div><div class="line">/*------------------------------------用户模块---------------------------------------*/</div><div class="line">#创建用户表</div><div class="line">DROP TABLE IF EXISTS `ugo_user`;</div><div class="line">create table ugo_user(</div><div class="line">	user_id int unsigned not null auto_increment primary key comment '用户编号',</div><div class="line">	user_name varchar(50) not null default '' comment '用户名',</div><div class="line">	tel char(12) not null default '' comment '手机号码',</div><div class="line">	email varchar(50) not null default '' comment '电子邮箱',</div><div class="line">	password char(32) not null default '' comment '用户密码,md5加密',</div><div class="line">	reg_time int unsigned not null default 0 comment '用户注册时间'</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">#创建用户收货地址表</div><div class="line">DROP TABLE IF EXISTS `ugo_address`;</div><div class="line">create table ugo_address(</div><div class="line">	address_id int unsigned not null auto_increment primary key comment '地址编号',</div><div class="line">	user_id int unsigned not null default 0 comment '地址所属用户ID',</div><div class="line">	consignee varchar(60) not null default '' comment '收货人姓名',</div><div class="line">	province smallint unsigned not null default 0 comment '省份，保存是ID',</div><div class="line">	city smallint unsigned not null default 0 comment '市',</div><div class="line">	district smallint unsigned not null default 0 comment '区',</div><div class="line">	street varchar(100) not null default '' comment '街道地址',</div><div class="line">	zipcode varchar(10) not null default '' comment '邮政编码',</div><div class="line">	telephone varchar(20) not null default '' comment '电话',</div><div class="line">	mobile varchar(20) not null default '' comment '移动电话',</div><div class="line">	index user_id(user_id)</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">#创建地区表，包括省市区三级</div><div class="line">DROP TABLE IF EXISTS `ugo_region`;</div><div class="line">create table ugo_region(</div><div class="line">	region_id smallint unsigned not null auto_increment primary key comment '地区ID',</div><div class="line">	parent_id smallint unsigned not null default 0 comment '父ID',</div><div class="line">	region_name varchar(30) not null default '' comment '地区名称',</div><div class="line">	region_type tinyint unsigned not null default 1 comment '地区类型 1 省份 2 市 3 区(县)'</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">#创建购物车表</div><div class="line">DROP TABLE IF EXISTS `ugo_cart`;</div><div class="line">create table ugo_cart(</div><div class="line">	cart_id int unsigned not null auto_increment primary key comment '购物车ID',</div><div class="line">	user_id int unsigned not null default 0 comment '用户ID',</div><div class="line">	goods_id int unsigned not null default 0 comment '商品ID',</div><div class="line">	goods_name varchar(100) not null default '' comment '商品名称',</div><div class="line">	goods_img varchar(50) not null default '' comment '商品图片',</div><div class="line">	goods_attr varchar(255) not null default '' comment '商品属性',</div><div class="line">	goods_number smallint unsigned not null default 1 comment '商品数量',</div><div class="line">	market_price decimal(10,2) not null default 0 comment '市场价格',</div><div class="line">	goods_price decimal(10,2) not null default 0 comment '成交价格',</div><div class="line">	subtotal decimal(10,2) not null default 0 comment '小计'</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line">/*------------------------------------用户模块 end-----------------------------------*/</div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line">/*------------------------------------订单模块---------------------------------------*/</div><div class="line">#创建送货方式表</div><div class="line">DROP TABLE IF EXISTS `ugo_shipping`;</div><div class="line">create table ugo_shipping(</div><div class="line">	shipping_id tinyint unsigned not null auto_increment primary key comment '编号',</div><div class="line">	shipping_name varchar(30) not null default '' comment '送货方式名称',</div><div class="line">	shipping_desc varchar(255) not null default '' comment '送货方式描述',</div><div class="line">	shipping_fee decimal(10,2) not null default 0 comment '送货费用',</div><div class="line">	enabled tinyint unsigned not null default 1 comment '是否启用，默认启用'</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line"></div><div class="line">#创建支付方式表</div><div class="line">DROP TABLE IF EXISTS `ugo_payment`;</div><div class="line">create table ugo_payment(</div><div class="line">	pay_id tinyint unsigned not null auto_increment primary key comment '支付方式ID',</div><div class="line">	pay_name varchar(30) not null default '' comment '支付方式名称',</div><div class="line">	pay_desc varchar(255) not null default '' comment '支付方式描述',</div><div class="line">	enabled tinyint unsigned not null default 1 comment '是否启用，默认启用'</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line"></div><div class="line">#创建订单表</div><div class="line">DROP TABLE IF EXISTS `ugo_order`;</div><div class="line">create table ugo_order(</div><div class="line">	order_id int unsigned not null auto_increment primary key comment '订单ID',</div><div class="line">	order_sn varchar(30) not null default '' comment '订单号',</div><div class="line">	user_id int unsigned not null default 0 comment '用户ID',</div><div class="line">	address_id int unsigned not null default 0 comment '收货地址id',</div><div class="line">	order_status tinyint unsigned not null default 0 comment '订单状态 1 待付款 2 待发货 3 已发货 4 已完成',</div><div class="line">	postscripts varchar(255) not null default '' comment '订单附言',</div><div class="line">	shipping_id tinyint not null default 0 comment '送货方式ID',</div><div class="line">	pay_id tinyint not null default 0 comment '支付方式ID',</div><div class="line">	goods_amount decimal(10,2) not null default 0 comment '商品总金额',</div><div class="line">	order_amount decimal(10,2) not null default 0 comment '订单总金额',</div><div class="line">	order_time int unsigned not null default 0 comment '下单时间',</div><div class="line">	index user_id(user_id),</div><div class="line">	index address_id(address_id),</div><div class="line">	index pay_id(pay_id),</div><div class="line">	index shipping_id(shipping_id)</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line"></div><div class="line">#创建订单明细表,即商品订单关系表（多对多）</div><div class="line">DROP TABLE IF EXISTS `ugo_order_goods`;</div><div class="line">create table ugo_order_goods(</div><div class="line">	rec_id int unsigned not null auto_increment primary key comment '编号',</div><div class="line">	order_id int unsigned not null default 0 comment '订单ID',</div><div class="line">	goods_id int unsigned not null default 0 comment '商品ID',</div><div class="line">	goods_name varchar(100) not null default '' comment '商品名称',</div><div class="line">	goods_img varchar(50) not null default '' comment '商品图片',</div><div class="line">	shop_price decimal(10,2) not null default 0 comment '商品价格',</div><div class="line">	goods_price decimal(10,2) not null default 0 comment '成交价格',</div><div class="line">	goods_number smallint unsigned not null default 1 comment '购买数量',</div><div class="line">	goods_attr varchar(255) not null default '' comment '商品属性',</div><div class="line">	subtotal decimal(10,2) not null default 0 comment '商品小计'</div><div class="line">)engine=MyISAM charset=utf8;</div><div class="line"></div><div class="line">/*------------------------------------订单模块 end-----------------------------------*/</div><div class="line">#创建后台管理员表</div><div class="line">DROP TABLE IF EXISTS ugo_admin;</div><div class="line">CREATE TABLE ugo_admin(</div><div class="line">	admin_id TINYINT UNSIGNED auto_increment PRIMARY KEY COMMENT '管理员id' ,</div><div class="line">	admin_name VARCHAR(50) NOT NULL COMMENT '用户名' ,</div><div class="line">	admin_pwd VARCHAR(50) NOT NULL COMMENT '密码' ,</div><div class="line">	admin_role_id TINYINT UNSIGNED NOT NULL COMMENT '角色编号'</div><div class="line">) ENGINE = INNODB charset = utf8 COMMENT '管理员表';</div><div class="line"># 超级管理员测试数据</div><div class="line">insert into ugo_admin values (null,'aa','aa',0);</div><div class="line"></div><div class="line">#创建后台权限表</div><div class="line">DROP TABLE IF EXISTS ugo_authority;</div><div class="line">CREATE TABLE ugo_authority(</div><div class="line">	auth_id INT UNSIGNED auto_increment PRIMARY KEY COMMENT 'auth_id' ,</div><div class="line">	auth_name VARCHAR(50) NOT NULL COMMENT '权限名称' ,</div><div class="line">	auth_pid INT UNSIGNED NOT NULL COMMENT '权限父级id' ,</div><div class="line">	auth_c VARCHAR(50) NULL COMMENT '控制器名' ,</div><div class="line">	auth_a VARCHAR(50) NULL COMMENT '方法名' ,</div><div class="line">	auth_path VARCHAR(50) NULL COMMENT '全路径,格式:父级id-子级id' ,</div><div class="line">	is_show TINYINT NOT NULL DEFAULT 1 COMMENT '是否显示在导航栏上'</div><div class="line">) ENGINE = INNODB charset = utf8 COMMENT '权限表';</div><div class="line"></div><div class="line">#创建后台角色表</div><div class="line">DROP TABLE IF EXISTS ugo_role;</div><div class="line">CREATE TABLE IF NOT EXISTS ugo_role(</div><div class="line">	role_id TINYINT UNSIGNED auto_increment PRIMARY KEY COMMENT 'role_id' ,</div><div class="line">	role_name VARCHAR(50) NOT NULL COMMENT '角色名称' ,</div><div class="line">	role_auth_ids VARCHAR(255) NOT NULL COMMENT '角色具有权限id的集合，格式1,2,5' ,</div><div class="line">	role_auth_ac text NOT NULL COMMENT '控制器和方法的组合，格式：控制器-方法名'</div><div class="line">) ENGINE = INNODB charset = utf8 COMMENT '角色表';</div><div class="line"></div><div class="line"># *********************************************************** #</div><div class="line">-- 插入测试数据</div><div class="line">insert into ugo_authority values (1,'商品管理',0,'','',1,1);</div><div class="line">insert into ugo_authority values (2,'会员管理',0,'','',2,1);</div><div class="line">insert into ugo_authority values (3,'权限管理',0,'','',3,1);</div><div class="line"></div><div class="line">insert into ugo_authority values (4,'商品列表',1,'Goods','show','1-4',1);</div><div class="line">insert into ugo_authority values (5,'添加商品',1,'Goods','add','1-5',1);</div><div class="line">insert into ugo_authority values (6,'修改商品',1,'Goods','edit','1-6',0);</div><div class="line">insert into ugo_authority values (7,'删除商品',1,'Goods','del','1-7',0);</div><div class="line"></div><div class="line">insert into ugo_authority values (8,'会员列表',2,'Role','show','2-12',1);</div><div class="line">insert into ugo_authority values (9,'添加会员',2,'Role','add','2-13',1);</div><div class="line">insert into ugo_authority values (10,'修改会员',2,'Role','edit','2-14',0);</div><div class="line">insert into ugo_authority values (11,'删除会员',2,'Role','del','2-15',0);</div><div class="line"></div><div class="line">insert into ugo_authority values (12,'权限列表',3,'Authority','show','3-8',1);</div><div class="line">insert into ugo_authority values (13,'添加权限',3,'Authority','add','3-9',1);</div><div class="line">insert into ugo_authority values (14,'修改权限',3,'Authority','edit','3-10',0);</div><div class="line">insert into ugo_authority values (15,'删除权限',3,'Authority','del','3-11',0);</div><div class="line"></div><div class="line">insert into ugo_role values (1,'经理','1,4,5','Goods-show,Goods-add');</div><div class="line">insert into ugo_role values (2,'主管','1,4','Goods-show');</div><div class="line"></div><div class="line">insert into ugo_admin values (null,'aa','aa',0)</div><div class="line"># *********************************************************** #</div></pre></td></tr></table></figure>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/数据库设计/" rel="tag">#数据库设计</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/20161017-2.html" rel="next" title="模板引擎">
                <i class="fa fa-chevron-left"></i> 模板引擎
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/20161018-1.html" rel="prev" title="反射 | PDO">
                反射 | PDO <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <!-- Go to www.addthis.com/dashboard to customize your tools -->
<script type = "text/javascript" src = "//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-57838eee5e2620d0" async = "async" ></script>
      
    </div>
  </div>


          </div>
          

  <p>热评文章</p>
  <div class="ds-top-threads" data-range="weekly" data-num-items="4"></div>


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="20161017-3.html"
           data-title="数据库设计-商城购物系统" data-url="http://blog.uiste.com/20161017-3.html">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.png"
               alt="uiste" />
          <p class="site-author-name" itemprop="name">uiste</p>
          <p class="site-description motion-element" itemprop="description">Stay Hungry，Stay Foolish</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">70</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              
                <span class="site-state-item-count">13</span>
                <span class="site-state-item-name">分类</span>
              
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">55</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/uiste" target="_blank" rel="external nofollow" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://weibo.com/uiste" target="_blank" rel="external nofollow" title="微博">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  微博
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://www.zhihu.com/people/uiste" target="_blank" rel="external nofollow" title="知乎">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  知乎
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              友情链接
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.uiste.com" title="uiste 个人博客" target="_blank">uiste 个人博客</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://uiste.github.io" title="uiste 技术博客" target="_blank">uiste 技术博客</a>
                </li>
              
            </ul>
          </div>
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#数据库设计"><span class="nav-number">1.</span> <span class="nav-text">数据库设计</span></a></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2015 - 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">uiste</span>
</div>

<div class="powered-by">
  由 <a class="theme-link" href="http://hexo.io" rel="external nofollow">Hexo</a> 趋势动力
</div>
<!--站长统计-->
<script src="https://s95.cnzz.com/z_stat.php?id=1259894121&web_id=1259894121" language="JavaScript"></script>
<!--<div class="theme-info">
  Theme -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next" rel="external nofollow">
    NexT.Mist
  </a>
</div> -->
&nbsp;&nbsp;&nbsp;本站总点击 <span id="busuanzi_value_site_pv"></span> 次
&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;您是第 <span id="busuanzi_value_site_uv"></span> 位访客

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>

<script>
(function(){
    var bp = document.createElement('script');
    bp.src = '//push.zhanzhang.baidu.com/push.js';
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.1"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"uiste"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    <script src="/vendors/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  






  
  
  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
       search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body").append('<div class="popoverlay">').css('overflow', 'hidden');
      $('.popup').toggle();

    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
    'use strict';
    $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
            // get the contents from search data
            isfetched = true;
            $('.popup').detach().appendTo('.header-inner');
            var datas = $( "entry", xmlResponse ).map(function() {
                return {
                    title: $( "title", this ).text(),
                    content: $("content",this).text(),
                    url: $( "url" , this).text()
                };
            }).get();
            var $input = document.getElementById(search_id);
            var $resultContent = document.getElementById(content_id);
            $input.addEventListener('input', function(){
                var matchcounts = 0;
                var str='<ul class=\"search-result-list\">';
                var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                $resultContent.innerHTML = "";
                if (this.value.trim().length > 1) {
                // perform local searching
                datas.forEach(function(data) {
                    var isMatch = true;
                    var content_index = [];
                    var data_title = data.title.trim().toLowerCase();
                    var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                    var data_url = data.url;
                    var index_title = -1;
                    var index_content = -1;
                    var first_occur = -1;
                    // only match artiles with not empty titles and contents
                    if(data_title != '' && data_content != '') {
                        keywords.forEach(function(keyword, i) {
                            index_title = data_title.indexOf(keyword);
                            index_content = data_content.indexOf(keyword);
                            if( index_title < 0 && index_content < 0 ){
                                isMatch = false;
                            } else {
                                if (index_content < 0) {
                                    index_content = 0;
                                }
                                if (i == 0) {
                                    first_occur = index_content;
                                }
                            }
                        });
                    }
                    // show search results
                    if (isMatch) {
                        matchcounts += 1;
                        str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                        var content = data.content.trim().replace(/<[^>]+>/g,"");
                        if (first_occur >= 0) {
                            // cut out 100 characters
                            var start = first_occur - 20;
                            var end = first_occur + 80;
                            if(start < 0){
                                start = 0;
                            }
                            if(start == 0){
                                end = 50;
                            }
                            if(end > content.length){
                                end = content.length;
                            }
                            var match_content = content.substring(start, end);
                            // highlight all keywords
                            keywords.forEach(function(keyword){
                                var regS = new RegExp(keyword, "gi");
                                match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                            });

                            str += "<p class=\"search-result\">" + match_content +"...</p>"
                        }
                        str += "</li>";
                    }
                })};
                str += "</ul>";
                if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
                if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
                $resultContent.innerHTML = str;
            });
            proceedsearch();
        }
    });}

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };

    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".popoverlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>


  

  

  

</body>
</html>
